<template>
	<view>
		<button @click="onSetTimeCall()">单次计时器setTimeout</button>
		<button @click="onSetTimeCallxy(userName,pwd)">带参数setTimeout</button>
		<button @click="onTimeOut()" type="warn">取消定时器</button>
		<button @click="onInteral()" type="primary">周期定时器</button>
		<button @click="onClearInteral()" type="warn"plain="true">取消定时器</button>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userName:'xx',
				pwd:'123',
				timeOutId:null,
				count:1,
				intearId:null
				
			}
		},
		methods: {
			onSetTimeCall(){
				console.log("onSetTimeCall");
				this.timeOutId=setTimeout(()=>{
					
				},2000)
			},
			onSetTimeCallxy(name,pwd){
				console.log("onSetTimeCallxy-->name:"+name+",pwd:"+pwd);
				setTimeout((x,y)=>{
					console.log();
				},2000,name,pwd)
			},
			onTimeOut(){
				console.log("onTimeOut, 取消");
				clearTimeout(this.timeOutId)
			},
			onInteral(){
				this.intearId=setInterval(()=>{
					this.count++;
					console.log("周期",this.count);
				},1000)
			},
			onClearInteral(){
					console.log("周期",this.intearId);
				clearInterval(this.intearId)
			},
			
		}
	}
</script>

<style>
button{
	margin: 30rpx;
}
</style>
